﻿function BindMyPaginationClick(resultSelector, searchApiUrl, requestParameter) {
    var pageSize = 5;
    if (!isNaN(requestParameter.pageSize) && requestParameter.pageSize > 0) {
        pageSize = requestParameter.pageSize;
    }
    requestParameter.pageSize = pageSize;
    $.post(searchApiUrl, requestParameter, function (data) {
        $(resultSelector).html(data);
        var totalCount = parseInt($("table[data-total]").attr("data-total"));
        var pageCount = parseInt((totalCount - 1) / pageSize + 1);
        if (!isNaN(totalCount) && totalCount > 0) {
            $("#mypage").jPaginator({
                selectedPage: 1,
                nbPages: pageCount,
                nbVisible: 9,
                //withSlider: true,
                //speed: 5,
                //coeffAcceleration: 2,
                overBtnLeft: '#mypage #over_left',
                overBtnRight: '#mypage #over_right',
                maxBtnLeft: '#mypage #min_left',
                maxBtnRight: '#mypage #max_right',
                minSlidesForSlider: 2,
                onPageClicked: function (a, num) {
                    requestParameter.pageIndex = num - 1;
                    $(resultSelector).load(searchApiUrl, requestParameter);
                }
            });
            $("#mypage").show();
        }
    });
}
